<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
<link href="__TMPL__/public/assets/themes/{:cmf_get_admin_style()}/house.css" rel="stylesheet">

<script type="text/html" id="photos-item-tpl">
  <li id="saved-image{id}">
      <input id="photo-{id}" type="hidden" name="picture_urls[]" value="{filepath}">
      <input class="form-control" id="photo-{id}-name" type="text" name="picture_names[]" value="{name}"
             style="width: 200px;" title="图片名称">
      <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
           onclick="imagePreviewDialog(this.src);">
      <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
      <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
  </li>
</script>
<script type="text/html" id="slides-item-tpl">
  <li id="saved-image{id}">
      <input id="photo-{id}" type="hidden" name="slide_urls[]" value="{filepath}">
      <input class="form-control" id="photo-{id}-name" type="text" name="slide_names[]" value="{name}"
             style="width: 200px;" title="图片名称">
      <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
           onclick="imagePreviewDialog(this.src);">
      <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
      <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
  </li>
</script>
<script type="text/html" id="files-item-tpl">
  <li id="saved-file{id}">
      <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
      <input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
             style="width: 200px;" title="文件名称">
      <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
      <a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
      <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
  </li>
</script>
</head>
<body>
<div class="wrap js-check-wrap house-add">
    <ul class="nav nav-tabs">
        <li><a href="{:url('index')}">房源管理</a></li>
        <li><a href="{:url('add')}">添加房源</a></li>
        <li class="active"><a href="javascript:void(0);">修改房源</a></li>
    </ul>
    <form action="{:url('editForm')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <input id="post-id" type="hidden" name="post[id]" value="{$data.id}">
        <div class="row">
            <div class="col-md-9">
                <table class="table table-bordered">
                    <tr>
                        <th width="100">标题<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text" name="post[title]" id="title" required value="{$data.title}" placeholder="请输入标题"/>
                        </td>
                    </tr>
                    <tr>
                        <th>关键词</th>
                        <td>
                            <input class="form-control" type="text" name="post[keywords]" id="keywords" value="{$data->getData('keywords')}" placeholder="请输入关键字">
                            <p class="help-block">多关键词之间用逗号或空格隔开</p>
                        </td>
                    </tr>
                    <tr>
                        <th>展示图片</th>
                        <td>
                            <ul id="slides" class="pic-list list-unstyled form-inline">
                              <notempty name="data.profile.slides">
                                  <foreach name="data.profile.slides" item="vo">
                                      <php>$img_url=cmf_get_image_preview_url($vo['url']);</php>
                                      <li id="slides-image{$key}">
                                          <input id="photo-{$key}" type="hidden" name="slide_urls[]"
                                                 value="{$vo.url}">
                                          <input class="form-control" id="slides-{$key}-name" type="text"
                                                 name="slide_names[]"
                                                 value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">
                                          <img id="photo-{$key}-preview"
                                               src="{:cmf_get_image_preview_url($vo['url'])}"
                                               style="height:36px;width: 36px;"
                                               onclick="parent.imagePreviewDialog(this.src);">
                                          <a href="javascript:uploadOneImage('图片上传','#slides-{$key}');">替换</a>
                                          <a href="javascript:(function(){$('#slides-image{$key}').remove();})();">移除</a>
                                      </li>
                                  </foreach>
                              </notempty>
                            </ul>
                            <a href="javascript:uploadMultiImage('图片上传','#slides','slides-item-tpl');"
                               class="btn btn-default btn-sm">选择图片</a>
                        </td>
                    </tr>
                    <tr>
                        <th>价格</th>
                        <td>
                          <p class="display-ib">
                            <span>总售价</span>
                            <input class="input-text" type="text" name="post[price]" size="8" id="price" value="{$data.price}" placeholder="单位元">
                          </p>
                          <p class="display-ib">
                            <span>每平售价</span>
                            <input class="input-text" type="text" name="post[univalent]" size="6" id="source" value="{$data.univalent}" placeholder="单位元">
                          </p>
                        </td>
                    </tr>
                    <tr>
                        <th>房屋信息</th>
                        <td>
                          <p class="display-ib">
                            <span>面积</span>
                            <input class="input-text" type="text" name="post[acreage]" size="8" id="source" value="{$data.acreage}" placeholder="单位平方米">
                          </p>
                          <p class="display-ib">
                            <span>户型选择</span>
                            <select class="input-text valid" name="post[structure_type]">
                              <option value="">请选择</option>
                              <?php if (isset($selectData[1])) { ?>
                              <foreach name="selectData[1]" item="name" key="value">
                                <option value="{$value}" <?php if($value == $data->structure_type) {echo 'selected="selected"';} ?>>{$name}</option>
                              </foreach>
                              <?php } ?>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>装修类型</span>
                            <select class="input-text valid" name="post[decoration_type]">
                              <option value="">请选择</option>
                              <?php if (isset($selectData[2])) { ?>
                              <foreach name="selectData[2]" item="name" key="value">
                                <option value="{$value}" <?php if($value == $data->decoration_type) {echo 'selected="selected"';} ?>>{$name}</option>
                              </foreach>
                              <?php } ?>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>朝向</span>
                            <select class="input-text valid" name="post[direction]">
                              <option value="">请选择</option>
                              <?php if (isset($selectData[4])) { ?>
                              <foreach name="selectData[4]" item="name" key="value">
                                <option value="{$value}" <?php if($value == $data->direction) {echo 'selected="selected"';} ?>>{$name}</option>
                              </foreach>
                              <?php } ?>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>用途</span>
                            <select class="input-text valid" name="post[purpose]">
                              <option value="">请选择</option>
                              <?php if (isset($selectData[3])) { ?>
                              <foreach name="selectData[3]" item="name" key="value">
                                <option value="{$value}" <?php if($value == $data->purpose) {echo 'selected="selected"';} ?>>{$name}</option>
                              </foreach>
                              <?php } ?>
                            </select>
                          </p>
                        </td>
                    </tr>
                    <tr>
                        <th>位置信息</th>
                        <td>
                          <p class="display-ib">
                            <span>小区名</span>
                            <input class="input-text" type="text" name="post[estate_name]" id="estate_name" value="{$data.estate_name}" placeholder="小区名">
                          </p>
                          <p class="display-ib">
                            <span>地址</span>
                            <input class="input-text" type="text" size="40" name="post[address]" id="address" value="{$data.address}" placeholder="地址">
                          </p>
                          <p class="display-ib">
                            <span>所属区域</span>
                            <select class="input-text valid" name="post[region]">
                              <option value="">请选择</option>
                              <?php if (isset($selectData[7])) { ?>
                              <foreach name="selectData[7]" item="name" key="value">
                                <option value="{$value}" <?php if($value == $data->region) {echo 'selected="selected"';} ?>>{$name}</option>
                              </foreach>
                              <?php } ?>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>位置坐标</span>
                            <input class="input-text" type="text" name="post[position]" id="position" value="{$data.position}" placeholder="位置坐标">
                            <a href="https://lbs.qq.com/tool/getpoint/" target="_blank">坐标获取器</a>
                          </p>
                        </td>
                    </tr>
                    <tr>
                        <th>产权信息</th>
                        <td>
                          <p class="display-ib">
                            <span>购买年份</span>
                            <input class="input-text" type="text" name="post[years]" size="6" id="years" value="{$data.years}" placeholder="例：2018">
                          </p>
                          <p class="display-ib">
                            <span>产权</span>
                            <input class="input-text" type="text" name="post[property_year]" id="property_year" value="{$data.property_year}" placeholder="单位年，例：70">
                          </p>
                        </td>
                    </tr>
                    <tr>
                        <th>楼层</th>
                        <td>
                          <p class="display-ib">
                            <span>所在楼层</span>
                            <input class="input-text" type="text" name="post[floor]" id="estate_name" value="{$data.floor}" placeholder="例：10">
                          </p>
                          <p class="display-ib">
                            <span>总楼层</span>
                            <input class="input-text" type="text" name="post[floorall]" id="estate_name" value="{$data.top_floor}" placeholder="例：20">
                          </p>
                          <p class="display-ib">
                            <span>楼层类型</span>
                            <select class="input-text valid" name="post[floor_type]">
                              <option value="">请选择</option>
                              <?php if (isset($selectData[5])) { ?>
                              <foreach name="selectData[5]" item="name" key="value">
                                <option value="{$value}" <?php if($value == $data->floor_type) {echo 'selected="selected"';} ?>>{$name}</option>
                              </foreach>
                              <?php } ?>
                            </select>
                          </p>
                        </td>
                    </tr>
                    <tr>
                        <th>交易信息</th>
                        <td>
                          <p class="display-ib">
                            <span>两税</span>
                            <select class="input-text valid" name="post[two_tax]">
                              <option value="">请选择</option>
                              <option value="有" <?php if('有' == $data->two_tax) {echo 'selected="selected"';} ?>>有</option>
                              <option value="无" <?php if('无' == $data->two_tax) {echo 'selected="selected"';} ?>>无</option>
                              <option value="个税" <?php if('个税' == $data->two_tax) {echo 'selected="selected"';} ?>>个税</option>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>税务承担</span>
                            <select class="input-text valid" name="post[tax_bear_type]">
                              <option value="">请选择</option>
                              <?php if (isset($selectData[6])) { ?>
                              <foreach name="selectData[6]" item="name" key="value">
                                <option value="{$value}" <?php if($value == $data->tax_bear_type) {echo 'selected="selected"';} ?>>{$name}</option>
                              </foreach>
                              <?php } ?>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>是否欠缴</span>
                            <select class="input-text valid" name="post[arrears]">
                              <option value="-1">请选择</option>
                              <option value="是" <?php if('是' == $data->arrears) {echo 'selected="selected"';} ?>>欠缴</option>
                              <option value="否" <?php if('否' == $data->arrears) {echo 'selected="selected"';} ?>>未欠缴</option>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>户口</span>
                            <select class="input-text valid" name="post[hukou]">
                              <option value="-1">请选择</option>
                              <option value="1" <?php if('1' == $data->hukou) {echo 'selected="selected"';} ?>>有</option>
                              <option value="0" <?php if('0' == $data->hukou) {echo 'selected="selected"';} ?>>无</option>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>最佳带看时间</span>
                            <input class="input-text valid" type="text" name="post[daikanshijian]" value="{$data.daikanshijian}">
                          </p>
                          <p class="display-ib">
                            <span>倒房时间</span>
                            <input class="input-text valid" type="text" name="post[daofang]" value="{$data.daofang}">
                          </p>
                          <p class="display-ib">
                            <span>其他说明</span>
                            <input class="input-text valid" type="text" name="post[qitashuoming]" value="{$data.qitashuoming}">
                          </p>
                        </td>
                    </tr>
                    <tr>
                        <th>佣金</th>
                        <td>
                          <p class="display-ib">
                            <span>成交奖励</span>
                            <input class="input-text" type="text" name="post[reward]" id="estate_name" size="50" value="{$data.reward}" placeholder="奖励说明">
                          </p>
                        </td>
                    </tr>
                    <tr>
                        <th>咨询电话</th>
                        <td>
                          <input class="input-text" type="text" name="post[contact]" id="contact" size="11" value="{$data.contact}" placeholder="咨询电话">
                        </td>
                    </tr>
                    <tr>
                        <th>其他信息</th>
                        <td>
                          <p class="display-ib">
                            <span>房源类型</span>
                            <select class="input-text valid" name="post[myself]">
                              <option value="">请选择</option>
                              <?php select_list($selectData['myself'], $data->myself); ?>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>出售情况</span>
                            <select class="input-text valid" name="post[sell_type]">
                              <option value="">请选择</option>
                              <?php select_list($selectData['sell_type'], $data->getData('sell_type')); ?>
                            </select>
                          </p>
                          <p class="display-ib">
                            <span>是否有密码</span>
                            <select class="input-text valid" name="post[password]">
                              <option value="">请选择</option>
                              <?php select_list($selectData['password'], $data->password); ?>
                            </select>
                          </p>
                        </td>
                    </tr>
                    <tr>
                        <th>房源介绍</th>
                        <td>
                            <script type="text/plain" id="content" name="post[content]">{$data.profile.content}</script>
                        </td>
                    </tr>
                    <tr>
                        <th>带看流程</th>
                        <td>
                          <textarea name="post[process]" rows="8" cols="80">{$data.profile->getData('process')}</textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>位置图片</th>
                        <td>
                            <ul id="photos" class="pic-list list-unstyled form-inline">
                              <notempty name="data.profile.position_picture">
                                  <foreach name="data.profile.position_picture" item="vo">
                                      <php>$img_url=cmf_get_image_preview_url($vo['url']);</php>
                                      <li id="saved-image{$key}">
                                          <input id="photo-{$key}" type="hidden" name="picture_urls[]"
                                                 value="{$vo.url}">
                                          <input class="form-control" id="photo-{$key}-name" type="text"
                                                 name="picture_names[]"
                                                 value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">
                                          <img id="photo-{$key}-preview"
                                               src="{:cmf_get_image_preview_url($vo['url'])}"
                                               style="height:36px;width: 36px;"
                                               onclick="parent.imagePreviewDialog(this.src);">
                                          <a href="javascript:uploadOneImage('图片上传','#photo-{$key}');">替换</a>
                                          <a href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>
                                      </li>
                                  </foreach>
                              </notempty>
                            </ul>
                            <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
                               class="btn btn-default btn-sm">选择图片</a>
                        </td>
                    </tr>
                    <tr>
                        <th>视频</th>
                        <td class="form-inline">
                            <input id="file-video" class="form-control" type="text" name="post[video_address]"
                                     value="{$data.video_address|default=''}" placeholder="填写腾讯视频vid" style="width: 200px;">
                            <a href="https://v.qq.com/" target="_blank">腾讯视频</a>
                        </td>
                    </tr>
                </table>
                <hook name="portal_admin_article_edit_view_main"/>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
                        <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <table class="table table-bordered">
                    <tr>
                        <th><b>首图展示</b></th>
                    </tr>
                    <tr>
                        <td>
                            <div style="text-align: center;">
                                <input type="hidden" name="post[thumb]" id="thumbnail" value="{$data->getData('thumb')|default=''}">
                                <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                                  <?php if (empty($data->thumb)) { ?>
                                      <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                           id="thumbnail-preview"
                                           width="135" style="cursor: pointer"/>
                                      <?php } else { ?>
                                      <img src="{:cmf_get_image_preview_url($data->getData('thumb'))}"
                                           id="thumbnail-preview"
                                           width="135" style="cursor: pointer"/>
                                  <?php } ?>
                                </a>
                                <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
                            </div>
                        </td>
                    </tr>
                </table>

                <hook name="portal_admin_article_edit_view_right_sidebar"/>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });
</script>
</body>
</html>
